package com.example.springboot.config.kafka;

import org.apache.kafka.clients.admin.NewTopic;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.config.TopicBuilder;

/**
 * @Author:ChenZhangKun
 * @Date: 2021/5/25 17:21
 */
//@Configuration
public class TopicConfig {
    /**
     * 配置一个topic
     * 指定名称及分区和副本数
     *
     * @return
     */
    @Bean
    public NewTopic topic() {
        NewTopic topic = TopicBuilder
                .name("second")
                .partitions(1)
                .replicas(1)
                .build();
        return topic;
    }
}
